package com.hwadee.teachingprocessmanagementsystem.controller.base;

import com.hwadee.teachingprocessmanagementsystem.entity.Classroom;
import com.hwadee.teachingprocessmanagementsystem.service.base.ClassroomService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;

/**
 * 教室表(Classroom)表控制层
 *
 * @author makejava
 * @since 2024-07-11 14:20:02
 */
@RestController
@RequestMapping("classroom")
public class ClassroomController {
    /**
     * 服务对象
     */
    @Resource
    private ClassroomService classroomService;


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<Classroom> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.classroomService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param classroom 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<Classroom> add(Classroom classroom) {
        return ResponseEntity.ok(this.classroomService.insert(classroom));
    }

    /**
     * 编辑数据
     *
     * @param classroom 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<Classroom> edit(Classroom classroom) {
        return ResponseEntity.ok(this.classroomService.update(classroom));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.classroomService.deleteById(id));
    }

}

